/**
 * 
 */
package ihm;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;

import appli.utils.Config;

/**
 * Ce panneau affiche la voiure tout simplement
 * 
 * @author Etienne Sainton
 * @since 0.4
 * @version 0.4
 */
public class SmaPanel extends JPanel {

	/**
	 * Useless ?
	 */
	private Point position;
	
	/**
	 * contains telemeter panels & masscenterpanels (LayeredPane)
	 */
	private VehicleLayered vehicleLayered;
	
	/**
	 * Panel width
	 */
	private final int width;
	
	/**
	 * Panel height
	 */
	private final int height;
	
	
	/**
	 * 
	 * @param width la largeur
	 * @param height la hauteur
	 */
	public SmaPanel(int width, int height) {
		//position = origin;
		this.width = width;
		this.height = height;
		this.setPreferredSize(new Dimension(width, height));
		this.setOpaque(false);
		this.setBackground(Color.BLACK);
	    this.setForeground(Color.black);
	   
	    this.setBounds(0, 0, width, height);
	    
	    vehicleLayered = new VehicleLayered(height);
	}
	
	/**
	 * Build voiture panel
	 */
	public void buildVoiturePanel(){
		
		vehicleLayered.build();
		
		this.add(vehicleLayered);
		this.validate();
		this.repaint();
		vehicleLayered.repaint();
		
	}
	
	/*@Override
	public void paint(Graphics g) {
		// TODO Auto-generated method stub
		
		vehicleLayered.repaint();
		g.setColor(Color.black);
		g.fillRect(0, 0, width, height);
		
	}*/

	/**
	 * Set a vehicleLayered
	 * @param vehicleLayered Le layer qui représente le véhicule
	 */
	public void setVehicleLayered(VehicleLayered vehicleLayered) {
		this.vehicleLayered = vehicleLayered;
	}
	
	/**
	 * Add a telemeterPanel
	 * @param panel le panel du télémètre
	 */
	public void addTelemeterPanel(TelemetrePanel panel){
		this.vehicleLayered.addTelemeterPanel(panel);
	}

	/**
	 * 
	 * @return MassCenterPanel
	 */
	public MassCenterPanel getMassCenterPanel() {
		return this.vehicleLayered.getMassCenterPanel();
	}


}
